package com.kele.base.id;

import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.Configurable;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.factory.spi.CustomIdGeneratorCreationContext;

import java.lang.reflect.Member;

public class SnowflakeGenerator implements Configurable, IdentifierGenerator {

    public SnowflakeGenerator() {
    }

    public SnowflakeGenerator(SnowflakeIdSequence config, Member annotatedMember,
                              CustomIdGeneratorCreationContext context) {
    }

    private final static IdWorker ID_WORKER;

    static {
        ID_WORKER = new IdWorker();
    }

    @Override
    public Object generate(SharedSessionContractImplementor sharedSessionContractImplementor, Object o) {
        return ID_WORKER.nextId();
    }
}
